<#macro ruleEditor>

<!-- Modal -->
<div class="modal" id="rule-modal" tabindex="-1" role="dialog" aria-labelledby="rule-modalLabel" aria-hidden="true">
  <div id="demo-main" class="modal-dialog" style="width:800px" >
    <div class="modal-content" >
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="ruel-modalLabel">规则编辑</h4>
      </div>
      <div class="modal-body" id="rule-modal-body" style="padding:0;border-radius: 6px;background:#eeeeee">
      		<iframe src="${rc.getContextPath()}/rule/ruleEditor.jhtml" id="rule_editor" name="rule_editor"
      			 width="798px" height="450px" scrolling="no" frameborder="no" border="0"></iframe>
     		<div style="text-align: right;padding:0 10px 10px 10px;">
        		<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>&nbsp;&nbsp;
        		<button type="button" class="btn btn-primary" id="test">确定</button>
        	</div> 
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
$(function(){
	$('#test').on('click',function(){
		ruleModal.onSure(window.frames['rule_editor'].RuleEditor.getValue());
		window.frames['rule_editor'].RuleEditor.resetEditor();
		$('#rule-modal').modal('hide');
	});
});

var ruleModal={
	onSure:function(ruleEditorText){
		
	},
	show:function(content,ruleDics,append){
		if(ruleDics)
		{
			var ruleEditor=this.preAddRuleDics=window.frames['rule_editor'].RuleEditor;
			if(!append)
			{
				for(i=0;this.preNodes&&i<this.preNodes.length;i++)
					ruleEditor.removeRuleDicNode(this.preNodes[i])
			}	
			this.preNodes=ruleEditor.addRuleDicNodes(ruleDics);
		}
		ruleEditor.setContent(content);
		$('#rule-modal').modal('show');
		
	},
	getValue:function(){
		window.frames['rule_editor'].RuleEditor.getValue();
	}
};

</script>

</#macro>